<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>{block name="title"}数据库表自动化{/block}</title>

    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
    <link href="__STATIC__/bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet"/>
    <link href="__STATIC__/font-awesome/css/font-awesome.min.css" type="text/css" rel="stylesheet"/>
    <link href="__STATIC__/back/css/stylesheet.css" type="text/css" rel="stylesheet" media="screen"/>
    <script type="text/javascript" src="__STATIC__/jquery/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="__STATIC__/bootstrap/js/bootstrap.min.js"></script>
    <style>
            .title {
                text-align: center;
            }

            input[type="checkbox"] {
                margin: 10px 40px 0 !important;
            }
    </style>
</head>

<body>
<div id="container">
    {include file="common/header" /}
    {block name="content"}
    <div class="page-header">
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:;" data-toggle="tooltip" title="表信息" class="btn btn-default" id="info_btn">
                    <i class="fa fa-info"></i>
                </a>
                <button type="submit" form="form-generate" data-toggle="tooltip" title="生成" class="btn btn-primary" id="make_btn">
                    <i class="fa fa-save"></i>
                </button>

            </div>
            <h1>数据表信息</h1>

        </div>
    </div>
    <div class="container-fluid">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">
                    <i class="fa fa-pencil"></i>
                    数据表信息
                </h3>
            </div>
            <div class="panel-body">
                <form action="{:url('generate')}" method="post" enctype="multipart/form-data" id="form-generate"
                      class="form-horizontal">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#tab-general" data-toggle="tab">数据表信息</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="tab-general">

                            <div class="form-group required">
                                <label class="col-sm-2 control-label" for="input-table">表名</label>
                                <div class="col-sm-10">
                                    <input type="text" name="table_name" value="member" placeholder="表名（不含前缀）"
                                           id="input-table" class="form-control"/>
                                    {present name="msg.title"}
                                    <label class="text-danger" id="input-title-error"
                                           for="input-table">{$msg.title}</label>
                                    {/present}

                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label" for="input-mark">备注</label>
                                <div class="col-sm-10">
                                    <input type="text" name="mark" value="" placeholder="备注"
                                           id="input-mark" class="form-control"/>

                                </div>
                            </div>
                            <div class="form-group title">
                                <div class="col-sm-2"></div>
                                <div class="col-sm-2">字段</div>
                                <div class="col-sm-2">名称</div>
                                <div class="col-sm-1">列表</div>
                                <div class="col-sm-1">排序</div>
                                <div class="col-sm-1">搜索</div>
                                <div class="col-sm-1">设置</div>
                                <div class="col-sm-1">必须</div>
                            </div>
                            <div class="field_content">

                            </div>


                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    {/block}
    {include file="common/footer" /}

</div>

<script src="__STATIC__/back/js/common.js" type="text/javascript"></script>

<script src="__STATIC__/validate/jquery.validate.min.js"></script>
<script src="__STATIC__/validate/additional-methods.min.js"></script>
<script src="__STATIC__/validate/localization/messages_zh.min.js"></script>
<div id="think_page_trace"
     style="position: fixed;bottom:0;right:0;font-size:14px;width:100%;z-index: 999999;color: #000;text-align:left;font-family:'微软雅黑';">
    <div id="think_page_trace_tab" style="display: none;background:white;margin:0;height: 250px;">
        <div id="think_page_trace_tab_tit"
             style="height:30px;padding: 6px 12px 0;border-bottom:1px solid #ececec;border-top:1px solid #ececec;font-size:16px">
            <span style="color:#000;padding-right:12px;height:30px;line-height:30px;display:inline-block;margin-right:3px;cursor:pointer;font-weight:700">基本</span>
            <span style="color:#000;padding-right:12px;height:30px;line-height:30px;display:inline-block;margin-right:3px;cursor:pointer;font-weight:700">文件</span>
            <span style="color:#000;padding-right:12px;height:30px;line-height:30px;display:inline-block;margin-right:3px;cursor:pointer;font-weight:700">流程</span>
            <span style="color:#000;padding-right:12px;height:30px;line-height:30px;display:inline-block;margin-right:3px;cursor:pointer;font-weight:700">错误</span>
            <span style="color:#000;padding-right:12px;height:30px;line-height:30px;display:inline-block;margin-right:3px;cursor:pointer;font-weight:700">SQL</span>
            <span style="color:#000;padding-right:12px;height:30px;line-height:30px;display:inline-block;margin-right:3px;cursor:pointer;font-weight:700">调试</span>
        </div>
        <div id="think_page_trace_tab_cont" style="overflow:auto;height:212px;padding:0;line-height: 24px">
            <div style="display:none;">
                <ol style="padding: 0; margin:0">
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">请求信息 : 2018-03-12 10:26:21
                        HTTP/1.1 GET : xiang.shop.com/back/brand/create
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">运行时间 : 0.045711s [
                        吞吐率：21.88req/s ] 内存消耗：2,479.30kb 文件加载：49
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">查询信息 : 2 queries 0 writes
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">缓存信息 : 0 reads,0 writes</li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">配置加载 : 65</li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">会话信息 :
                        SESSION_ID=ecfp4os2g3sfan1565ji14bfp1
                    </li>
                </ol>
            </div>
            <div style="display:none;">
                <ol style="padding: 0; margin:0">
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">E:\WWW\shop1\public\index.php
                        ( 0.75 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\start.php ( 0.72 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\base.php ( 2.60 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Loader.php ( 20.23 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\vendor\composer\autoload_namespaces.php ( 0.15 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\vendor\composer\autoload_psr4.php ( 0.37 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\vendor\composer\autoload_classmap.php ( 0.14 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Error.php ( 3.75 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Config.php ( 6.38 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\convention.php ( 10.10 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\App.php ( 20.87 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Request.php ( 48.47 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\application\config.php ( 8.10 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\application\database.php ( 1.74 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Hook.php ( 4.71 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\application\tags.php ( 0.96 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\application\common.php ( 2.95 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Env.php ( 1.21 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\helper.php ( 17.30 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Lang.php ( 7.23 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Log.php ( 6.04 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\lang\zh-cn.php ( 11.58 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\application\route.php ( 2.37 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Route.php ( 58.71 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\application\back\tags.php ( 0.25 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\application\back\common.php ( 1.62 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\application\back\controller\BrandController.php ( 7.47 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Controller.php ( 6.01 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\traits\controller\Jump.php ( 4.90 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\View.php ( 6.77 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\view\driver\Think.php ( 5.45 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Template.php ( 45.15 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\template\driver\File.php ( 2.17 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Debug.php ( 7.13 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\application\back\behavior\CheckAuth.php ( 1.27 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Session.php ( 10.86 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\application\back\model\Admin.php ( 0.35 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Model.php ( 67.72 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\extend\priv\Privilege.php ( 2.49 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Db.php ( 6.67 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\db\connector\Mysql.php ( 3.89 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\db\Connection.php ( 29.66 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\db\Query.php ( 88.70 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\db\builder\Mysql.php ( 4.22 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\db\Builder.php ( 30.77 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\runtime\temp\7ca1b5ee5379622ae55093768b59874b.php ( 25.57 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Url.php ( 12.72 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Response.php ( 8.33 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\debug\Html.php ( 4.16 KB )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">
                        E:\WWW\shop1\thinkphp\library\think\Cache.php ( 6.10 KB )
                    </li>
                </ol>
            </div>
            <div style="display:none;">
                <ol style="padding: 0; margin:0">
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">[ LANG ]
                        E:\WWW\shop1\thinkphp\lang\zh-cn.php
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">[ ROUTE ] array (
                        'type' =&gt; 'module',
                        'module' =&gt;
                        array (
                        0 =&gt; 'back',
                        1 =&gt; 'brand',
                        2 =&gt; 'create',
                        ),
                        )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">[ HEADER ] array (
                        'cookie' =&gt; 'thinkphp_show_page_trace=0|0;
                        __guid=45836717.454255442028417600.1520820537856.2283; monitor_count=1;
                        thinkphp_show_page_trace=0|0; PHPSESSID=ecfp4os2g3sfan1565ji14bfp1',
                        'accept-language' =&gt; 'zh-CN,zh;q=0.8',
                        'accept-encoding' =&gt; 'gzip, deflate, sdch',
                        'accept' =&gt; 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
                        'user-agent' =&gt; 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
                        Chrome/55.0.2883.87 Safari/537.36',
                        'upgrade-insecure-requests' =&gt; '1',
                        'connection' =&gt; 'close',
                        'host' =&gt; 'xiang.shop.com',
                        )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">[ PARAM ] array (
                        )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">[ SESSION ] INIT array (
                        'id' =&gt; '',
                        'var_session_id' =&gt; '',
                        'prefix' =&gt; 'think',
                        'type' =&gt; '',
                        'auto_start' =&gt; true,
                        )
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">[ DB ] INIT mysql</li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">[ BEHAVIOR ] Run
                        app\back\behavior\CheckAuth @action_begin [ RunTime:0.021065s ]
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">[ RUN ]
                        app\back\controller\BrandController-&gt;createAction[
                        E:\WWW\shop1\application\back\controller\BrandController.php ]
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">[ VIEW ]
                        E:\WWW\shop1\public/../application/back\view\brand\create.html [ array (
                        0 =&gt; 'message',
                        1 =&gt; 'data',
                        ) ]
                    </li>
                </ol>
            </div>
            <div style="display:none;">
                <ol style="padding: 0; margin:0">
                </ol>
            </div>
            <div style="display:none;">
                <ol style="padding: 0; margin:0">
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">[ DB ] CONNECT:[
                        UseTime:0.001200s ] mysql:host=127.0.0.1;dbname=shop1;charset=utf8
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">[ SQL ] SHOW COLUMNS FROM
                        `shop_role_admin` [ RunTime:0.008340s ]
                    </li>
                    <li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">[ SQL ] SELECT COUNT(*) AS
                        tp_count FROM `shop_role_admin` `ra` INNER JOIN `shop_role` `r` ON `ra`.`role_id`=`r`.`id` WHERE
                        `ra`.`admin_id` = 1 AND `r`.`is_super` = '1' LIMIT 1 [ RunTime:0.000620s ]
                    </li>
                </ol>
            </div>
            <div style="display:none;">
                <ol style="padding: 0; margin:0">
                </ol>
            </div>
        </div>
    </div>
    <div id="think_page_trace_close"
         style="display:none;text-align:right;height:15px;position:absolute;top:10px;right:12px;cursor:pointer;"><img
            style="vertical-align:top;"
            src=""/>
    </div>
</div>
<div id="think_page_trace_open"
     style="height:30px;float:right;text-align:right;overflow:hidden;position:fixed;bottom:0;right:0;color:#000;line-height:30px;cursor:pointer;">
    <div style="background:#232323;color:#FFF;padding:0 6px;float:right;line-height:30px;font-size:14px">0.048834s</div>
    <img width="30" style="" title="ShowPageTrace"
         src="">
</div>


</body>
</html>
</title>
</head>
<body>

</body>
</html>
<script>
    $("#info_btn").click(function () {
        table= $("#input-table").val();
        if(table=="") return;
        url = "{:url('info')}";
        data = { "table_name" : table };
        $.get(url,data,function (res) {
            console.log(res);
            $(".field_content").html("");
            $("#input-mark").val(res.comment);
            html="";
            $.each(res.fields,function (i,e) {
                check =  $.inArray(e.COLUMN_NAME,["update_time","create_time","sort","id"])==-1?"checked":"";
                check2 =  $.inArray(e.COLUMN_NAME,["update_time","create_time","id"])==-1?"checked":"";
                console.log(check);
                html+='<div class="form-group">';
                html+='<div class="col-sm-2"></div>';
                html+='<div class="col-sm-2"><input type="text" readonly class="form-control" name="field['+i+'][name]" value="'+e.COLUMN_NAME+'" '+check+'></div>';
                html+='<div class="col-sm-2"><input type="text" readonly class="form-control" name="field['+i+'][cname]" value="'+e.COLUMN_COMMENT+'"'+check+'></div>';
                html+='<div class="col-sm-1"><input type="checkbox" class="form-control" name="field['+i+'][list]" '+check+'></div>';
                html+='<div class="col-sm-1"><input type="checkbox" class="form-control" name="field['+i+'][sort]"'+check+'></div>';
                html+='<div class="col-sm-1"><input type="checkbox" class="form-control" name="field['+i+'][search]" '+check2+'></div>';
                html+='<div class="col-sm-1"><input type="checkbox" class="form-control"  name="field['+i+'][option]" '+check+'></div>';
                html+='<div class="col-sm-1"><input type="checkbox" class="form-control"  name="field['+i+'][require]"'+check+'></div></div>';

            });
            $(".field_content").html(html);

        },'json');
    });
</script>